package com.moyu.auth.controller;


import cn.dev33.satoken.util.SaResult;
import com.moyu.auth.dto.UserLoginDTO;
import com.moyu.auth.dto.UserRegDTO;
import com.moyu.auth.service.ILoginAndRegService;
import com.moyu.common.core.controller.BaseController;
import com.moyu.common.core.domain.R;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登陆注册相关操作控制层
 *
 * @Author 赵彦博
 * @Date 2024/12/30 16:43
 */
@RestController
@RequestMapping("/loginAndReg")
@Tag(name = "登录注册相关接口")
public class LoginAndRegController extends BaseController {

    @Autowired
    private ILoginAndRegService loginAndRegService;

    @PostMapping("/doLogin")
    public SaResult doLogin(@RequestBody UserLoginDTO userLoginDTO) {
        return loginAndRegService.doLogin(userLoginDTO);
    }

    @PostMapping("/reg")
    public R<Void> reg(@RequestBody UserRegDTO userRegDTO) {
        return toR(loginAndRegService.reg(userRegDTO));
    }

}
